var a = getApp();

Page({
    data: {
        customBalance: "",
        info: "",
        member: "",
        popupSpecs: !1,
        payPwd: "",
        isTapPay: !1
    },
    onLoad: function(a) {
        var t = a.info, e = a.member;
        t = JSON.parse(t), e = JSON.parse(e), t || wx.redirectTo({
            url: "/packageI/personRed/personListDetail/personListDetail"
        }), this.setData({
            info: t,
            member: e
        });
        try {
            var s = wx.getStorageSync("yz_basic_info");
            this.setData({
                customBalance: s.balance.balance ? s.balance.balance : "余额"
            });
        } catch (a) {
            console.log(a);
        }
    },
    onReady: function() {},
    onShow: function() {},
    payment: function() {
        this.data.isTapPay || (this.setData({
            isTapPay: !0
        }), !0 === this.data.member.need_password ? this.setData({
            popupSpecs: !0
        }) : this.payPost());
    },
    popupSpecsClose: function(a) {
        this.setData({
            popupSpecs: !1,
            isTapPay: !1
        });
    },
    onPassword: function(a) {
        this.setData({
            payPwd: a.detail,
            isTapPay: !1
        }), a.detail && this.getVerifyPassword(a.detail);
    },
    getVerifyPassword: function(t) {
        var e = this, s = a.getNetAddresss("payment.password.check");
        s += "&password=" + t, a._getNetWork({
            url: s,
            success: function(a) {
                var t = a.data;
                1 == t.result ? e.payPost() : wx.showModal({
                    title: "提示",
                    content: t.msg,
                    success: function(a) {
                        a.confirm ? 2001 == t.data.code || (2002 == t.data.code ? wx.navigateTo({
                            url: "/packageA/member/set_balance_password/set_balance_password"
                        }) : t.data.code) : a.cancel && (2001 == t.data.code || 2002 == t.data.code || t.data.code);
                    }
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    payPost: function() {
        var t = this, e = a.getNetAddresss("plugin.redpack-user.frontend.redpack.send"), s = JSON.stringify(this.data.info);
        a._getNetWork({
            url: e,
            data: {
                redpack_date: s
            },
            success: function(a) {
                t.setData({
                    isTapPay: !1
                }), 1 === a.data.result ? (wx.showToast({
                    title: a.data.msg,
                    mask: !0,
                    duration: 1e3
                }), t.timer = setTimeout(function() {
                    wx.redirectTo({
                        url: "/packageI/personRed/personRed/personRed"
                    });
                }, 1e3)) : wx.showModal({
                    title: "提示",
                    content: a.data.msg
                });
            },
            fail: function() {
                this.setData({
                    isTapPay: !1
                });
            }
        });
    },
    onUnload: function() {
        clearTimeout(this.timer);
    }
});